
#ifndef _ICOMBOBOARD_H_
#define _ICOMBOBOARD_H_

#include <BIcon>
#include <BImage>
#include <BButton>
#include <BTabWidget>
#include <BScrollArea>
#include "IAlignItem.h"

namespace BWE
{
	class TabItem : public IAlignItem
	{
	public:
		inline TabItem(BWidget* widget = 0) : IAlignItem(0)
		{
			this->widget = widget;
			if (this->widget)
			{
				text = widget->title();
				icon = widget->icon();
				visible = true;
			}
		}
		inline TabItem(const TabItem& other) : IAlignItem(other)
		{
			widget = other.widget;
			visible = other.visible;
			closeButton = other.closeButton;
		}

		virtual void translateText(const BStyle* style);

		virtual void freshSize(const BFont* font, int width);

		inline bool operator == (const BObject* object) const
		{
			return this->widget == object;
		}
		inline bool operator == (const BString& title) const
		{
			return widget && widget->title() == title;
		}

		BValue			asset;
		BWidget*		widget;
		bool			visible;
		BRect			closeArea;
		BButtonHolder	closeButton;
	};

	class ITabBoard : public BScrollArea
	{
		friend class BTabWidget;
	public:
		ITabBoard(BTabWidget* tabWidget);
		~ITabBoard();

		void freshItemRects();

		virtual BSize sizeHint() const;

	protected:
		virtual void scrolling(Orientation orientation);

	protected:
		virtual void resizeEvent(const BEvent& event);

		virtual void styleEvent(const BEvent& event);
		virtual void freshEvent(const BEvent& event);
		virtual void paintEvent(const BEvent& event);

		virtual void keyPressEvent(const BKeyEvent& keyEvent);

		virtual void mouseEnterEvent(const BMouseEvent& mouseEvent);
		virtual void mouseLeaveEvent(const BMouseEvent& mouseEvent);

		virtual void mouseClickEvent(const BMouseEvent& mouseEvent);
		virtual void mouseMoveEvent(const BMouseEvent& mouseEvent);

	public:
		BTabWidget*			boss;
		BButton*			arrow;
		BArray<TabItem*>	items;
		BPoint				popupOffset;
		int					maxShowCount;

		mutable bool		dirty;
		BSize				iconSize;
		int					itemSpacing;
		int					hoveredIndex;
		int					pressedIndex;
		BSize				contentSize;
		int					showBegin;
		int					showEnd;


	};
}
#endif
